package day07;

public abstract class Animal {
    String name;
    int age;
    String color;
    Animal(String name,int age,String color){
        this.name=name;
        this.age=age;
        this.color=color;
    }
    void drink(){
        System.out.println("我是"+age+"岁的"+name+",我在喝水");
    }
    abstract void eat();
}
interface Swim{
     void swim();
}
class Dog extends Animal implements Swim{
    Dog(String name,int age,String color){
        super(name,age,color);
    }
    public void eat(){
        System.out.println("名字叫"+name+"的"+color+"狗在吃饭");
    }
    @Override
    public void swim(){
        System.out.println("名字叫"+name+"的"+color+"狗在游泳");
    }
    public void lookHome(){
        System.out.println("名字叫"+name+"的"+color+"狗在看家");
    }
}
class Chick extends Animal{
    Chick(String name,int age,String color){
        super(name, age, color);
    }
    @Override
    void eat() {
        System.out.println("名字叫"+name+"的"+color+"小鸡在啄米");
    }
    void layEggs(){
        System.out.println("名字叫"+name+"的"+color+"小鸡下蛋了");
    }
}
class Fish extends Animal implements Swim{
    Fish(String name,int age,String color){
        super(name, age, color);
    }
    @Override
    void eat() {
        System.out.println("名字叫"+name+"的"+color+"鱼儿在吃蚯蚓");
    }

    @Override
    public void swim() {
        System.out.println("名字叫"+name+"的"+color+"会游泳");
    }
}
class SwimTest {
    public static void main(String[] args){
        Dog dog =new Dog("大黄",5,"黄色");
        Chick chick =new Chick("小白",2,"白色");
        Fish fish =new Fish("小黑",1,"黑色");
        dog.eat();
        dog.swim();
        dog.lookHome();

        chick.eat();
        chick.layEggs();

        fish.eat();
        fish.swim();
    }
}